package com.im.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.im.dao.MemberDAO;
import com.im.entity.Member;


@WebServlet("/register")
public class RegisterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String message = "";
		
		String pw = request.getParameter("password");
		String confirm = request.getParameter("confirm");
		if(pw.equals(confirm)){
			Member member = new Member();
			member.setName(request.getParameter("name"));
			member.setPhone(request.getParameter("phone"));
			member.setEmail(request.getParameter("email"));
			member.setPassword(pw);
			message = MemberDAO.insert(member);
			
		}else{
			message = "Password Mismatch !!";
		}
		
		PrintWriter out = response.getWriter();
		out.println("<h1>"+message+"</h1>");

		
	}

}
